package com.blue.firecat.serivce.impl;

import com.blue.firecat.dao.NoteDao;
import com.blue.firecat.entity.Note;
import com.blue.firecat.serivce.NoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @描述
 * @时间 2017-8-9 11:55
 * @作者 肖亦鸣
 */
@Service
public class NoteServiceImpl implements NoteService {
    @Autowired
    NoteDao noteDao;

    @Override
    public int insertNote(Note note) {
        return noteDao.insert(note);
    }

    @Override
    public Note getByOrderId(Long orderId) {
        return noteDao.selectByPrimaryKey(orderId);
    }

    @Override
    public int updateByOrderId(Note note) {
        Note byOrderId = this.getByOrderId(note.getOrderId());
        if (byOrderId == null) {
            return noteDao.insert(note);
        } else {
            return noteDao.updateByPrimaryKeySelective(note);
        }
    }
}
